package cloud.dandanit.itservice.controller.givelike;


import cloud.dandanit.itservice.service.GiveLikeService;
import cloud.dandanit.itservice.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author luokai
 * @since 2022-07-03
 */
@RestController
@RequestMapping("/itservice/like")
public class GiveLikeController {

    @Autowired
    private GiveLikeService giveLikeService;

    /**
     * 获取点赞数
     * @return 点赞数
     */
    @GetMapping("getGiveLikeNum")
    public R getLikeNum() {

        Integer likeNum = giveLikeService.getGiveLikeNum();
        return R.ok().data("likeNum",likeNum);
    }


    /**
     * 增加点赞数(存redis)
     * @param likeNum 点赞数
     * @return 成功
     */
    @GetMapping("addGiveLikeNum/{likeNum}")
    public R addGiveLikeNum(@PathVariable String likeNum) {

        giveLikeService.addGiveLikeNumToRedis(likeNum);
        return R.ok();
    }

}

